package com.superbook.actions.register;

import com.opensymphony.xwork2.ActionSupport;
import com.superbook.config.SpringApplicationContext;
import com.superbook.mw.InitialRestaurantRegistrationBP;
import com.superbook.mw.to.InitialRestaurantRegistrationTO;

/**
 * This class is responsible to register First Time Registration by Restaurant Owners.
 * @author zen-rohitkumar
 *
 */
public class InitialRestaurantRegistration extends ActionSupport{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String city;
	private String area;
	private String restName;
	private String managerName;
	private String contactNumber;
	private String email;
	private String isCorporateDiscount;
	
	/**
	 * @return the isCorporateDiscount
	 */
	public String getIsCorporateDiscount() {
		return isCorporateDiscount;
	}
	/**
	 * @param isCorporateDiscount the isCorporateDiscount to set
	 */
	public void setIsCorporateDiscount(String isCorporateDiscount) {
		this.isCorporateDiscount = isCorporateDiscount;
	}
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the managerNameS
	 */
	public String getManagerName() {
		return managerName;
	}
	/**
	 * @param managerName the managerName to set
	 */
	public void setManagerName(String managerName) {
		this.managerName = managerName;
	}
	/**
	 * @return the contactNumber
	 */
	public String getContactNumber() {
		return contactNumber;
	}
	/**
	 * @param contactNumber the contactNumber to set
	 */
	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}
	/**
	 * @return the area
	 */
	public String getArea() {
		return area;
	}
	/**
	 * @param area the area to set
	 */
	public void setArea(String area) {
		this.area = area;
	}
	/**
	 * @return the city
	 */
	public String getCity() {
		return city;
	}
	/**
	 * @param city the city to set
	 */
	public void setCity(String city) {
		this.city = city;
	}
	/**
	 * @return the restName
	 */
	public String getRestName() {
		return restName;
	}
	/**
	 * @param restName the restName to set
	 */
	public void setRestName(String restName) {
		this.restName = restName;
	}
	
	public String execute() {
		System.out.println("Test");
		try{
			InitialRestaurantRegistrationTO registration = new InitialRestaurantRegistrationTO();
			/*if(city != null)
				registration.setCity(city);
			if(restName !=null)
				registration.setRestaurantName(restName);
			if(area != null)
				registration.setArea(area);
			if(managerName != null)
				registration.setManagerName(managerName);
			if(contactNumber != null) {
				Long contNumber = new Long(Long.parseLong(contactNumber));
				registration.setContactNumber(contNumber);
			}
			if(email != null)
				registration.setEmail(email);
			if(isCorporateDiscount != null)
				registration.setIsCorporateDiscount(isCorporateDiscount);*/
			registration.setArea("Pimple Saudagar");
			registration.setCity("Pune");
			registration.setContactNumber(new Long("8412876507"));
			registration.setEmail("rohitkumar.zen@gmail.com");
			registration.setIsCorporateDiscount("Y");
			registration.setManagerName("Rohit Kumar");
			registration.setRestaurantName("Rohit Restaurant");
			InitialRestaurantRegistrationBP registarationBP = (InitialRestaurantRegistrationBP) 
					SpringApplicationContext.getApplicationContext().getBean("initalRestRegistration");
			registarationBP.saveRegistration(registration);
			
		System.out.println("in Struts 2 Action Class: "+restName);
		
		
		return "SUCCESS";
		} catch(Exception e) {
			e.printStackTrace();
		}
		return "fail";
	}
	
	
}
